home *** CD-ROM | disk | FTP | other *** search
/ PCNet 2006 April / PCnet 2006-06.4.iso / shareware / nmsetup.exe / WebServer / web / uploadform.php < prev    next >
Encoding:
PHP Script  |  2006-05-01  |  11.0 KB  |  285 lines

  1. <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. // <!--Copyright (c) 2005 Pure Networks Inc.  All rights reserved.-->
  4. ////////////////////////////////////////////////////////////////////////////////
  5. //
  6. // Build: 3.0.6121.0 (Stable)
  7. // $Revision: #3 $
  8. //
  9. ini_set ( "zlib.output_compression", "Off" );
  10. ini_set ( "max_execution_time", "0" );
  11. $sNavLocation = "upload";
  12. require "_session_common.php";
  13.  
  14. ///////////////////////////////////////////////////
  15. // Make sure that we have a valid share passed in.
  16. ///////////////////////////////////////////////////
  17. if (!isset($_GET['share']) or $_GET['share'] == "")
  18. {
  19.     log_activity("QS check", "failure", return_error_text(200, "", $arErrors));
  20.     gotoAbs('/error/200/return');
  21.     exit();
  22. }
  23. else
  24. {
  25.     $sShare = $_GET['share'];
  26.     log_activity("view folder share", "info", $sShare);
  27. }
  28. ///////////////////////////////////////////////////
  29. // Make sure that we have a valid path passed in.
  30. ///////////////////////////////////////////////////
  31. if (!isset($_GET['path']) or $_GET['path'] == "")
  32. {
  33.     log_activity("QS check", "failure", return_error_text(201, "", $arErrors));
  34.     gotoAbs('/error/201/return');
  35.     exit();
  36. }
  37. else
  38. {
  39.     $sPath = urlDecodeString($_GET['path']);
  40.     log_activity("view folder path", "info", $sPath);
  41. }
  42. ///////////////////////////////////////////////////
  43. // Let's try to see if we can open the share
  44. ///////////////////////////////////////////////////
  45. try
  46. {
  47.     $nmSharedPlace = $nmNetworkLib->OpenShare($sShare);
  48. }
  49. catch(Exception $ex)
  50. {
  51.     log_activity("Attempting nmNetworkLib->OpenShare($sShare)", "exception", $ex->getMessage());
  52.     gotoAbs('/error/305/return');
  53.     exit();
  54. }
  55. ///////////////////////////////////////////////////
  56. // check to ensure upload is enabled.
  57. ///////////////////////////////////////////////////
  58. try
  59. {
  60.     $bReadOnly      = $nmSharedPlace->ReadOnly;
  61.     $bUploadEnabled = $nmRaManager->UploadsEnabled;
  62.     if ($bReadOnly)
  63.     {
  64.         log_activity("upload", "error", return_error_text(328, "", $arErrors));
  65.         goto('upload.php?errorcode=328&share=' . $sShare . '&path=' . $sPath);
  66.         exit();
  67.     }
  68.     if (!$bUploadEnabled)
  69.     {
  70.         log_activity("upload", "error", return_error_text(327, "", $arErrors));
  71.         goto('upload.php?errorcode=327&share=' . $sShare . '&path=' . $sPath);
  72.         exit();
  73.     }
  74.  
  75. }
  76. catch (exception $ex)
  77. {
  78.     log_activity("Attempting nmRaManager->UploadsEnabled", "exception", $ex->getMessage());
  79.     goto('upload.php?errorcode=307');
  80.     exit();
  81. }
  82. ?>
  83. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  84. <html>
  85. <head>
  86. <title><?php echo htmlspecialchars(returnPageTitle($sIntroHeadline, $sProductNameInformal, $nmSharedPlace, $sPath, $fileName)); ?></title>
  87. <?php
  88. require "_styles_import.php";
  89. ?>
  90. <script type="text/javascript" language="JavaScript">
  91. function upload_status()
  92. {
  93.     if (document.getElementById('userfile').value == "")
  94.     {
  95.         // they haven't picked a file, they have to browse first...
  96.     }
  97.     else
  98.     {
  99.         if (verify_file_is_valid())
  100.         {
  101.             document.getElementById('Form1').submit();
  102.             document.getElementById('UploadTable').style.display='none';
  103.             document.getElementById('UploadTable').style.visibility='hidden';
  104.             document.getElementById('UploadHR').style.visibility='hidden';
  105.             document.getElementById('FileDialog').style.visibility='hidden';
  106.             document.getElementById('UploadStep2').style.visibility='visible';
  107.             return true;
  108.         }
  109.         else
  110.         {
  111.             return false;
  112.         }
  113.     }
  114. }
  115.  
  116. function verify_file_is_valid()
  117. {
  118.     sDisallowedExtensions = ("<?php echo ($sincDisallowedExtensions); ?>");
  119.     // let's get the file's extension
  120.     var str1 = document.getElementById('userfile').value.toLowerCase();
  121.     iPos = str1.lastIndexOf(".");
  122.     sFileExtension = str1.substr(iPos);
  123.  
  124.     // is the extension of a disallowed type?
  125.     if (sDisallowedExtensions.indexOf(sFileExtension) >= 0)
  126.     {
  127.         alert ('<?php echo (return_error_text(324, "", $arErrors)); ?>');
  128.         <?php
  129.         if ($btBrowserType != "macosxie")
  130.         {
  131.         ?>
  132.             document.getElementById('BrowseInput').value = '';
  133.             check_upload_button_enabled_state()
  134.             return false;
  135.         <?php
  136.         }
  137.         ?>
  138.     }
  139.     else
  140.     {
  141.         <?php
  142.         if ($btBrowserType != "macosxie")
  143.         {
  144.         ?>
  145.             document.getElementById('BrowseInput').value = document.getElementById('userfile').value;
  146.             var iLastSlashIndex = document.getElementById('userfile').value.lastIndexOf("\\");
  147.             var strFileName = document.getElementById('userfile').value.substr(iLastSlashIndex + 1);
  148.             document.getElementById('BrowseResults').innerHTML = "File to upload: " + strFileName;
  149.             check_upload_button_enabled_state();
  150.         <?php
  151.         }
  152.         ?>
  153.         return true;
  154.     }
  155. }
  156. </script>
  157. </head>
  158. <?php
  159. if ($btBrowserType != "macosxie")
  160. {
  161. ?>
  162. <body style="clip: rect(0px, 0px, 0px, 0px); overflow:hidden;" class="UploadBody">
  163. <!--Copyright (c) 2005 Pure Networks Inc.  All rights reserved.-->
  164. <?php
  165. }
  166. else
  167. {
  168. ?>
  169. <body>
  170. <!--Copyright (c) 2005 Pure Networks Inc.  All rights reserved.-->
  171. <?php
  172. }
  173. ?>
  174.  
  175. <table width="100%" border="0">
  176. <tr>
  177.     <td valign="top">
  178.         <!--Main Content Starts Here-->
  179.         <?php 
  180.         require "styles/default/default.inc";
  181.  
  182.         if ($btBrowserType != "macosxie")
  183.         {
  184. ?>
  185.             <script type="text/javascript">
  186.             function verify_file_is_picked()
  187.             {
  188.                 if (document.getElementById('BrowseInput').value != "")
  189.                 {
  190.                     return true;
  191.                 }
  192.                 else
  193.                 {
  194.                     return false;
  195.                 }
  196.             }
  197.             
  198.             function check_upload_button_enabled_state()
  199.             {
  200.                 if (verify_file_is_picked())
  201.                 {
  202.                     document.getElementById('upload').className='Button UploadButton';
  203.                 }
  204.                 else
  205.                 {
  206.                     document.getElementById('upload').className='ButtonDisabled UploadButton';        
  207.                 }
  208.             }
  209.             
  210.             function upload_mouse_out()
  211.             {
  212.                 if (verify_file_is_picked())
  213.                 {
  214.                     document.getElementById('upload').className='Button UploadButton';
  215.                 }
  216.                 else
  217.                 {
  218.                     document.getElementById('upload').className='ButtonDisabled UploadButton';        
  219.                 }
  220.             }
  221.             
  222.             function upload_mouse_over()
  223.             {
  224.                 if (verify_file_is_picked())
  225.                 {
  226.                     document.getElementById('upload').className='ButtonOver UploadButton';        
  227.                 }
  228.                 else
  229.                 {
  230.                     document.getElementById('upload').className='ButtonDisabled UploadButton';        
  231.                 }
  232.             }
  233.             </script>
  234.             <div class="UploadTable" id="UploadTable" style="visibility:visible;">
  235.                 <form id="Form1" name="Form1" method="post" runat="server" enctype="multipart/form-data" action="upload.php" onsubmit="return upload_status();">
  236.                 <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo ($iMaxFileSize); ?>"/>
  237.                 <input type="hidden" name="SHARE" value="<?php echo $sShare; ?>"/>
  238.                 <input type="hidden" name="page" value="<?php echo $_GET['page'];?>">
  239.                 <input type="hidden" name="PATH" value="<?php echo urlEncodeString($sPath); ?>"/>
  240.                 <label for="userfile"><div class="UploadFormHeader">Select a File to Upload to Your Network</div></label><br/>
  241.                 <div class="UploadFormText" id="BrowseResults" name="BrowseResults">Click <strong>Browse</strong>, and select a file.</div>
  242.                 <div class="UploadHR" id="UploadHR" style="visibility:visible;"> </div>
  243.                     <input type="hidden" name="BrowseInput" id="BrowseInput" class="BrowseInput" size="48" onchange="check_upload_button_enabled_state();"/>         
  244.                 <div style="position:relative;visibility:visible;" id="FileDialog">
  245.                     <input name="userfile" id="userfile" type="file" class="FileBrowseControl" size="1" onmouseover="document.getElementById('browse').className='ButtonOver BrowseButton'" onmouseout="document.getElementById('browse').className='Button BrowseButton'" onchange="verify_file_is_valid();"/>
  246.                     <div name="browse" id="browse" class="BrowseButton Button" onmouseover="this.className='BrowseButton ButtonOver'" onmouseout="this.className='BrowseButton Button'">    Browse...   </div>
  247.                     <a id="upload" class="UploadButton ButtonDisabled" onmouseover="upload_mouse_over();" onmouseout="upload_mouse_out();" href="javascript:upload_status();">Upload</a>
  248.                     <input type="submit" name="upload" value="Upload " style="position:relative; left:-250px;"/>
  249.                 </div>
  250.                 </form>
  251.             </div> <!-- end of Upload Table div -->
  252. <?php
  253.         }
  254.         else
  255.         {
  256. ?>
  257.             <div class="UploadTable" id="UploadTable" style="visibility:visible;">
  258.             <form id="Form1" name="Form1" method="post" runat="server" enctype="multipart/form-data" action="upload.php" onsubmit="return upload_status();">
  259.             <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo ($iMaxFileSize); ?>"/>
  260.                 <input type="hidden" name="SHARE" value="<?php echo $sShare; ?>"/>
  261.                 <input type="hidden" name="page" value="<?php echo $_GET['page'];?>">
  262.                 <input type="hidden" name="PATH" value="<?php echo urlEncodeString($sPath); ?>"/>
  263.             <label for="userfile"><div class="UploadFormHeader">Select a File to Upload to Your Network</div></label><br/>
  264.             <div class="UploadFormText">Click <strong>Browse</strong>, and select a file.</div>
  265.             <div class="UploadHR" id="UploadHR" style="visibility:visible;"> </div>
  266.             <div style="position:relative;visibility:visible;" id="FileDialog">
  267.                 <input name="userfile" id="userfile" type="file" size="15" class="FileBrowseControlMacIe" />
  268.                 <input type="submit" name="upload" value="Upload " "/>
  269.             </div>
  270.             </form>
  271.             <br/><br/>
  272.             </div> <!-- end of Upload Table div -->
  273. <?php
  274.         }
  275. ?>
  276.             <div class="UploadSetupTable" id="UploadStep2" style="visibility:hidden;display:inline;">
  277.                 <div class="UploadStatusHeader">Uploading file to your network</div>
  278.                 <br/><br/><div class="UploadStatusText">Please wait...</div>
  279.             </div>
  280.             <!-- Main content ends here -->
  281.     </td>
  282. </tr>
  283. </table>
  284. </body>
  285. </html>